package practice1_100;

import java.util.LinkedList;
import java.util.List;

public class Offer54 {
    public int kthLargest(TreeNode root, int k) {
        List<Integer> list=new LinkedList<Integer>();
        getList(root,list);
        return list.get(k);

    }
    public void getList(TreeNode root,List<Integer> list){
//        if(root.left==null&&root.right==null) return;
        if(root.right!=null)getList(root.right,list);
        list.add(root.val);
        if(root.left!=null)getList(root.left,list);

    }

    public static void main(String[] args) {
        new Offer54().kthLargest(new TreeNode(2,new TreeNode(1),new TreeNode(3)),1);
    }
}
